package com.jeejam.product.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.jeejam.framework.base.service.impl.BaseServiceImpl;
import com.jeejam.product.dao.ProductAttributeMapper;
import com.jeejam.product.pojo.ProductAttribute;
import com.jeejam.product.service.ProductAttributeService;

@Service
public class ProductAttributeServiceImpl extends BaseServiceImpl implements ProductAttributeService{
	
	private ProductAttributeMapper productAttributeMapper;
	
	@Resource
	public void setProductAttributeMapper(ProductAttributeMapper productAttributeMapper) {
		this.productAttributeMapper = productAttributeMapper;
		this.baseMapper = productAttributeMapper;
	}

	@Override
	public ProductAttribute get(int productId, int attributeId) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("productId", productId);
		params.put("attributeId", attributeId);
		return productAttributeMapper.selectByProductIdAndAttributeId(params);
	}

	@Override
	public void deleteByProductId(int productId) {
		productAttributeMapper.deleteByProductId(productId);
	}

	@Override
	public List<ProductAttribute> findByProductId(int productId) {
		return productAttributeMapper.selectByProductId(productId);
	}

}
